home *** CD-ROM | disk | FTP | other *** search
- Path: eagle.novo.dk!usenet
- From: morb@novo.dk (Morten Brun)
- Newsgroups: comp.lang.c++
- Subject: Unicode and c++ !!!
- Date: Mon, 22 Jan 1996 09:57:35 GMT
- Organization: Novo Nordisk
- Message-ID: <4dvmrv$bh0@eagle.novo.dk>
- NNTP-Posting-Host: dhcp250-178.novo.dk
- X-Newsreader: Forte Free Agent 1.0.82
-
- I am having a big problem when trying to convert from ascii to Unicode
- by using the wsprintf function. Here is a little "working" sample.
- Any help will be greately appreciated.
-
- #define UNICODE 1
- #include <windows.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <iostream.h>
-
- int Test(LPWSTR lpwszString);
- int err = 0;
-
- main()
- {
- char sAscii[255];
- LPWSTR sUniCode = NULL;
-
- // This works
- err = Test( TEXT("This is a ascii string"));
-
- // This does not work !!!!
- strcpy(sAscii,"This is a ascii string");
-
- wsprintf(sUniCode,TEXT("%S"),sAscii);
-
- err = Test(sUniCode);
-
- return( 0 );
- }
-
- int Test(LPWSTR lpwszString)
- {
- char sString[255];
-
- // Print the Unicode
- cout << "Unciode: " << lpwszString << endl;
-
- // Convert Unicode to Ascii
- sprintf (sString ,"%S",lpwszString);
- cout << "Ascii :" << sString << endl;
- return(0);
- }
-
-
-
- Morten Brun
- Novo Nordisk IT, Denmark
- morb@novo.dk
-
-